home *** CD-ROM | disk | FTP | other *** search
- /*
- sp_seer_glue.c - interface routine to the seer device
- */
- #include "sc.h"
- #include "sc_seer_globals.h"
- #include "sc_filter.h"
-
- /*
- do a seer control function
- */
- int seer_ctl(op,aarg)
- int op; /*the function to do*/
- SR_record_pt aarg; /*the seer control recor*/
- {SR_record_pt *arg_pt;
- int err;
- arg_pt=&aarg;
- err=Control(gl.seer_refnum,op,arg_pt);
- if(err!=noErr)
- bomb(BOMB_sr_gnrl,err,(long)op);
- return aarg->SR_error;
- }
-
- #define sp_hq_size 10000 /*use x bytes for seer header queue*/
- #define sp_dq_size 20000 /*use x bytes for seer data queue*/
- void configure_seer()
- {SR_record srarg; /*seer argument record*/
- gl.sp_header_q=NewPtr(sp_hq_size); /*allocate the header queue*/
- gl.sp_data_q=NewPtr(sp_dq_size); /*allocate the data queue*/
- if((gl.sp_header_q==NIL)||
- (gl.sp_data_q==NIL))
- bomb(BOMB_sr_cnf,BMB_no_os,0L);
- srarg.x.a_initq.dbufstart=gl.sp_data_q; /*where the data queue lives*/
- srarg.x.a_initq.dbuflen=sp_dq_size; /*how big the data queue is*/
- srarg.x.a_initq.hbufstart=gl.sp_header_q; /*where the header queue lives*/
- srarg.x.a_initq.hbuflen=sp_hq_size; /*how big the header queue is*/
- srarg.x.a_initq.filter_proc=packet_filter; /*routine to filter packets*/
- srarg.x.a_initq.filter_data=(Ptr)&my_filter;
- if(seer_ctl(SRc_initq,&srarg)!=SRe_noErr)
- bomb(BOMB_sr_cnf,BMB_no_os,srarg.SR_error);
- }
-
-
- void seer_clear()
- {SR_record srarg; /*seer argument record*/
- if(seer_ctl(SRc_clear_queue,&srarg)!=SRe_noErr)
- bomb(BOMB_sr_on,BMB_no_os,srarg.SR_error);
- }
-
- void seer_on()
- {SR_record srarg; /*seer argument record*/
- if(seer_ctl(SRc_on,&srarg)!=SRe_noErr)
- bomb(BOMB_sr_on,BMB_no_os,srarg.SR_error);
- }
-
-
- /*preform the seer on function*/
- void load_seer()
- {SR_record srarg; /*seer argument record*/
- srarg.x.a_load.major_version=SEER_MAJOR;
- if(seer_ctl(SRc_load,&srarg)!=SRe_noErr)
- bomb(BOMB_sr_load,BMB_no_os,srarg.SR_error);
- sp_status=srarg.x.a_load.status_pt;
- }
-
- void seer_off()
- {SR_record srarg; /*seer argument record*/
- if(seer_ctl(SRc_off,&srarg)!=SRe_noErr)
- bomb(BOMB_sr_on,BMB_no_os,srarg.SR_error);
- }
-
- /*
- close the seer device
- */
- void close_seer()
- {int err;
- if(gl.seer_refnum==0) /*already closed?*/
- return; /*yes, nothing to do then*/
- err=CloseDriver(gl.seer_refnum); /*close the driver*/
- if(err!=noErr) /*an error?*/
- if(gl.bomb_active<2) /*no, ok to call bomb()?*/
- bomb(BOMB_nodrvropen,BMB_no_os,err); /*yes, it isn't active now
- gl.seer_refnum=0; /*mark the device closed*/
- }
-
- void open_seer()
- {SR_record srarg; /*seer argument record*/
- int old_res_file;
- int err;
- if(gl.seer_refnum!=0) /*if already open nothing to do*/
- return;
- old_res_file=CurResFile(); /*remember so we can put current resource file back*/
- gl.seer_res_file=OpenResFile("\pseer_drvr"); /*open the device driver resource file*/
- if(gl.seer_res_file== -1) /*find the resource file?*/
- bomb(BOMB_nodrvrfile,ResError(),(long)0); /*no, belly up*/
- UseResFile(gl.seer_res_file); /*may already be open, search it*/
- err=OpenDriver("\p.seer",&gl.seer_refnum); /*open the driver*/
- if(err!=noErr) /*find the resource file?*/
- bomb(BOMB_nodrvropen,err,(long)0); /*no, belly up*/
- UseResFile(old_res_file); /*go back to the normal resource file*/
- }
-